<?php

$params = require(__DIR__ . '/params.php');

$components = require __DIR__ . '/components.php';
$components = array_merge($components, [
    'user' => [
        'class' => 'app\components\User',
        'identityClass' => 'app\models\User',
        'enableAutoLogin' => true,
        'loginUrl' => ['/'],
        'idParam' => '__uid'
    ],
    'admin' => [
        'class' => 'app\components\User',
        'identityClass' => 'app\models\Admin',
        'enableAutoLogin' => true,
        'loginUrl' => ['site/dashboard'],
        'idParam' => '__adminid'
    ],
    'errorHandler' => [
        'class' => 'app\components\ErrorHandler',
        'errorAction' => 'site/error',
    ],
    'request' => [
        'class' => 'app\components\Request',
        'cookieValidationKey' => 'vjjwoM2X95DLyN22_-XI8vVcL3EJlmiw',
        'enableCsrfValidation' => false,
        'parsers' => [
            'application/json' => 'yii\web\JsonParser'
        ]
    ],
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
            'admin/<controller:\w+>/<action:\w+>'=>'admin/<controller>/<action>',
            '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
        ],
    ],

]);
$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'name' => 'shake',
    'version' => 1.0,
    'modules' => [
        'api' => [
            'class' => 'app\modules\api\Module'
        ],
        'admin' => [
            'class' => 'app\modules\admin\Module'
        ],
    ],
    'components' => $components,
    'params' => $params,
];

if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
